package com.keyword.utils;



import java.util.ArrayList;
import java.util.List;

/**
 * @author yhx
 */
public class ListUtil {

    /**
     * 新旧列表返回增加列表
     * @param newList
     * @param oldList
     * @param <T>
     * @return
     */
    public static <T>List<T> getAddList(List<T> newList, List<T> oldList) {
        if (newList == null || newList.size() == 0) {
            return null;
        }
        if (oldList == null || oldList.size() == 0) {
            return newList;
        }
        ArrayList addList = new ArrayList<>();
        addList.addAll(newList);
        addList.removeAll(oldList);
        return  addList;
    }

    /**
     * 新旧列表返回删除列表
     * @param newList
     * @param oldList
     * @param <T>
     * @return
     */
    public static <T>List<T> getRemoveList(List<T> newList,List<T> oldList) {
        return getAddList(oldList, newList);
    }
}
